<script setup>
import { ref,reactive, nextTick,onActivated,getCurrentInstance,onMounted, watch  } from 'vue'; 
import { useRoute,useRouter } from 'vue-router';
import { ElMessage,ElMessageBox  } from 'element-plus';
import { useFreightData } from '../Hooks/index';

const { seachTable } = useFreightData()
const route = useRoute();
const router = useRouter();
const instance = getCurrentInstance();

// 新增编辑回退时候刷新列表
onActivated(()=>{

})
const formInline = ref([

    {
      type: "input",
      prop: "name",
      placeholder: "请输入配送方式名称",
      label: "",
      model: "",
    },
    {
        type: "select",
        placeholder: "请选择计算方式",
        label: '',
        prop: 'source1',
        data:[
            {
                label:"收入",
                value:1
            },
            {
                label:"卖出",
                value:2
            }
        ],
        model: "",
    },
])

const btnLefts = ref([
    {
      label:'新建',
      type:'primary',
      show:()=>true,
      img:new URL("@/assets/icon/btn-add.png",import.meta.url),
      click:()=>{
        router.push({
          name: "FreightAdd",
        });
      } 
    },
])
const btnRights = ref([
])

const tableConfig = ref([
    {
      prop: "phone",
      label: "配送方式名称",
      type:"slot",
      slotName:'phone',
      width:310
    },
    {
      prop: "idCard",
      label: "计算方式"
    },
    {
      prop: "idCard",
      label: "物流公司"
    },
    {
      type: "action",
      label: "操作",
      width: 200,
      btns: [
        {
          label: () => "编辑",
          type:"success",
          click: async (row) => {
            router.push({
              name: "FreightEdit",
              query: {
                uuid: row.uuid,
              },
            });
          },
        },
        {
          label: () => "删除",
          type:"danger",
          click: async (row) => {

          },
        },

      ],
    },
]);
const tableLoading = ref(false)
const totalPage = ref(0)
const tableData = ref([]);


const handlerSearch = async (formInline)=>{
    tableLoading.value = true;
    try{
        
        totalPage.value = 100;
        tableData.value = [
            {
                "doctorNumberCode": "YS000299",
                "type": "审方",
                "name": "12313",
                "mobile": "18207123212",
                "idCard": "",
                "frontUrl": "https://static.91medicine.net/images/20230919/2930e77d-fba7-4a7e-bbc4-f6815eca5a6d.jpg",
                "headUrl": "https://static.91medicine.net/images/20230919/f6159f8e-c44a-43cc-ae5c-3ddfc659cd7a.jpg",
                "introduce": "3123",
                "institutions": "九为（浙江）网络科技有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230919/d5e597c3-1c76-4646-a843-03b0b8686a03.jpg",
                "certificateNo": "312312",
                "titleValue": "",
                "uuid": "8a69c4628aab7785018aac0eb31f0004",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "",
                "source": "3"
            },
        ];
        tableLoading.value = false;
    }catch(e){
        tableLoading.value = false;
    }
}
</script>
<template>
    <div class="page-content">
        <SeachTable 
          :tableType="1"
          ref="seachTable"
          :tableIndex="true"
          :forms="formInline"
          :btnLefts="btnLefts"
          :btnRights="btnRights"
          :tableLoading="tableLoading"
          :tableConfig="tableConfig"
          :tableData="tableData"
          :totalPage="totalPage"
          @handlerSearch="handlerSearch"
          :tableWidth="70"
        >
        </SeachTable>
    </div>
</template>
<style lang="less" scoped>

</style>